package ast;

import compiler.OutputFormatter;

public class Operation extends Expression {
	
	private Expression leftExpression;
	private Expression rightExpression;
	private Operator operator;
	
	public Operation(Expression leftExpression, Operator operator, Expression rightExpression) {
		this.setLeftExpression(leftExpression);
		this.setOperator(operator);
		this.setRightExpression(rightExpression);
	}

	@Override
	public void genC(OutputFormatter of) {
		of.output("(");
		getLeftExpression().genC(of);
		of.space();
		getOperator().genC(of);
		of.space();
		getRightExpression().genC(of);
		of.output(")");
	}

    public void setLeftExpression(Expression leftExpression) {
        this.leftExpression = leftExpression;
    }

    public Expression getLeftExpression() {
        return leftExpression;
    }

    public void setRightExpression(Expression rightExpression) {
        this.rightExpression = rightExpression;
    }

    public Expression getRightExpression() {
        return rightExpression;
    }

    public void setOperator(Operator operator) {
        this.operator = operator;
    }

    public Operator getOperator() {
        return operator;
    }
}
